﻿@model FollowPeers.Models.UserProfile 
@{
    ViewBag.Title = @Model.FirstName + " " + @Model.LastName + " Update Files and Publications";
}
@Html.Partial("_Header")
<div class="container">
@Html.Partial("_SideBar1")
<div class="upload_file span9 main-content">
      @using (Html.BeginForm("UploadFile","Profile",FormMethod.Post,new {@encType = "multipart/form-data"}))
        {
            @Html.ValidationSummary(true)
            @Html.HiddenFor(model => model.UserProfileId)
            @Html.HiddenFor(model => model.UserName)
            @Html.HiddenFor(model => model.activated)
          
            <fieldset>
             <legend>Upload Files and Publications</legend>
             
             <input type='file' name='photo' id='photo' />
             </fieldset>
            
            
            <p>
                <input type="submit" name="submit" value="Save" style="float: right; padding: 3px 8px; cursor: pointer;">
            </p>
          
          <p>
           <table id="myDataTable" class="table table-hover" style="float: right; padding: 3px 8px; cursor: pointer;">
                <thead>
                    <tr>
                        <th>
                            Files Uploaded
                        </th>
                    </tr>
                </thead>
                <tbody>
                    
                    @{
                        string path = HttpRuntime.AppDomainAppPath;
                        string newpath = path + "\\Content\\Files\\";
                        var directoryInfo = new DirectoryInfo(newpath + Model.UserName + "\\");
                        if (directoryInfo.Exists)
                        {
                            string[] readtext = File.ReadAllLines(newpath + Model.UserName + "\\uploadedList.txt");
                            if (readtext == null || readtext.Length == 0)
                            {
                                
                               <p>There are no uploaded files</p>
                                    
                            }
                            
                            else
                            {
                                foreach (var fileName in readtext)
                                {
                                    <tr>
                                        <td>
                                            <p><a href="#">@fileName</a></p>
                                        </td>
                                        <td>
                                                @Html.ActionLink("Download", "Download", new { downloadPath = newpath + Model.UserName + "\\" + fileName }) 
          
                                        </td>
                                        <td>
                                                @Html.ActionLink("Delete", "Delete_File", new { delPath = newpath + Model.UserName + "\\" + fileName }) 
          
                                        </td>                           
                                    </tr>
                                }
                            }
                        }
                        
                        else{
                                <p>There are no uploaded files</p> 
                            }
                    }
                </tbody>
            </table>
        </p>
        }
       
</div>   
</div>


